<template>
  <div>
    <!-- <h3>xinwenxiangqing</h3> -->
    <div>
        <div v-for="item in newsinfo.process" :key="item.id" class="dv">
            {{item.pcontent}}
        </div>
    </div>
    <!-- 评论组件 -->
    <pinglun></pinglun>
  </div>
  
</template>

<script>
//导入组件分三步
// 1.0导入评论组件
import pinglun from "./pinglun.vue";

export default {
  data() {
    return {
      id: this.$route.params.id, //将url地址栏中的id传到data中
      newsinfo: []
    };
  },
  created() {
    //只要进到页面就执行getinfo()方法
    this.getinfo();
  },
  methods: {
    getinfo() {
      this.$http
        .get("https://api.oioweb.cn/api/Memu.php?key=鱼")
        .then(result => {
          if (result.body.code == 1) {
            console.log("获取info成功");
            this.newsinfo = result.body.data.list[0];
          } else {
            console.log("获取info失败");
            Toast("获取数据失败");
          }
        });
    }
  },
  //2.0使用导入的组件
  //3.0在页面上挂载一下
  components:{
      pinglun:pinglun
  }
};
</script>

<style scoped>
.dv{
    margin: 10px;
}
</style>